<template>
    <div>
        <c-header left-text="返回" title="服务反馈"></c-header>
        <van-form @submit="onSubmit">
            <van-field v-model="title" name="title" label="标题" placeholder="标题" :rules="[{ required: true, message: '请填写标题' }]" />
            <van-field v-model="content" type="textarea" rows="4" name="content" label="反馈内容" placeholder="反馈内容" :rules="[{ required: true, message: '请填写反馈内容' }]" />
            <div style="margin: 16px;">
                <van-button round block type="info" native-type="submit">提交</van-button>
            </div>
        </van-form>
    </div>
</template>

<script>
import api from "../../api";
export default {
    name: "service",
    data() {
        return { title: "", content: "", userId: "" };
    },
    mounted() {
        this.userId = JSON.parse(localStorage.getItem("userInfo")).id;
    },
    methods: {
        async onSubmit(values) {
            const response = await api.notice.addFeedback({
                userId: this.userId,
                type: 0,
                ...values,
            });
            this.$Toast(response.data.msg);
            this.title = "";
            this.content = "";
        },
    },
};
</script>

<style lang='less' scoped>
</style>